package com.pms.utils;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class HttpGetMaker {

	public static String sendGetRequest(String urlStr){
		URL url = null;
		HttpURLConnection httpURLConn = null;
		StringBuffer response = new StringBuffer();
		try {

			url = new URL(urlStr);
			httpURLConn = (HttpURLConnection) url.openConnection();
			// httpURLConn.setDoOutput(true);
			httpURLConn.setRequestMethod("GET");

			httpURLConn.connect();

			InputStream in = httpURLConn.getInputStream();
			BufferedReader bd = new BufferedReader(new InputStreamReader(in));
			String temp;
			while ((temp = bd.readLine()) != null) {
				response.append(temp);
			}
			in.close();
			bd.close();		
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (httpURLConn != null) {
				httpURLConn.disconnect();
			}
		}
		System.out.println(response.toString());
		return response.toString();
	}
}
